﻿using _05.建构者模式.Builders;
using _05.建构者模式.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05.建构者模式
{
    public class Client
    {
        public void Start()
        {
            Console.WriteLine($"2007年开始生产第一台苹果手机");
            IBuilder builder = new Iphone1Builder();//builder负责组装iphone1手机
            Director director = new Director(builder);//director指挥builder干活儿
            IPhone phone = director.DoWork();
            DoStuff(phone);

            Console.WriteLine("2023年苹果发布了IPhone15");
            director.DoWork(new Iphone15Builder());
            DoStuff(director.DoWork());

            Console.WriteLine("同年三星发布了GalaxyS24手机");
            director = new Director(new GalaxyS24Builder());
            DoStuff(director.DoBuild());

        }

        private void DoStuff(IPhone phone)
        {
            Console.WriteLine(phone.Name);
            Console.WriteLine(phone.CPU);
            Console.WriteLine(phone.Screen);
            Console.WriteLine(phone.Memory);
            Console.WriteLine(phone.Battery);
            Console.WriteLine(phone.Camera);
        }
    }
}
